package com.taxi.driver.api;

import com.taxi.driver.data.entity.CanGrapOrdersEntity;
import com.taxi.driver.data.entity.CancelDesEntity;
import com.taxi.driver.data.entity.ComplainResultEntity;
import com.taxi.driver.data.entity.OrderCostEntity;
import com.taxi.driver.data.entity.OrderEntity;
import com.taxi.driver.data.entity.OrderHomeStatusEntity;
import com.taxi.driver.data.entity.OrderSummaryEntity;
import com.taxi.driver.data.entity.WaitFare;
import com.taxi.driver.data.entity.WxpayInfo;

import java.util.List;

import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.POST;
import retrofit2.http.Path;
import rx.Observable;

/**
 * 功能描述："出租车/专车/快车"订单API
 * <p>
 * appid、noncestr和sign 这三个参数，将在RequestInterceptor中添加；调用接口时，无需传入这三个参数。
 * <p>
 * 但需要注意：如果除path外，还需要传其它参数，则要设置 @FormUrlEncoded
 */
public interface OrderApi {

    //获取首页订单状态
    @POST("{apiPath}/status.yueyue")
    Observable<OrderHomeStatusEntity> reqHomeStatus(@Path(value = "apiPath", encoded = true) String apiPath);

    //获取订单列表
    @FormUrlEncoded
    @POST("{apiPath}/list.yueyue")
    Observable<List<OrderSummaryEntity>> reqOrderList(@Path(value = "apiPath", encoded = true) String apiPath,
                                                      @Field("nowPage") int nowPage);

    //抢单
    @FormUrlEncoded
    @POST("{apiPath}/grab.yueyue")
    Observable<OrderEntity> reqGrab(@Path(value = "apiPath", encoded = true) String apiPath,
                                    @Field("orderUuid") String orderUuid);

    //获取订单详情
    @FormUrlEncoded
    @POST("{apiPath}/info.yueyue")
    Observable<OrderEntity> reqOrderDetail(@Path(value = "apiPath", encoded = true) String apiPath,
                                           @Field("orderUuid") String orderUuid);

    // 出发去接乘客
    @FormUrlEncoded
    @POST("{apiPath}/pickUpPas.yueyue")
    Observable<String> reqPickUpPas(@Path(value = "apiPath", encoded = true) String apiPath,
                                    @Field("orderUuid") String orderUuid,
                                    @Field("uploadText") String uploadText);

    // 到达上车地点
    @FormUrlEncoded
    @POST("{apiPath}/depart.yueyue")
    Observable<String> reqDepart(@Path(value = "apiPath", encoded = true) String apiPath,
                                 @Field("orderUuid") String orderUuid,
                                 @Field("uploadText") String uploadText);

    // 接到乘客
    @FormUrlEncoded
    @POST("{apiPath}/geton.yueyue")
    Observable<String> reqGetOn(@Path(value = "apiPath", encoded = true) String apiPath,
                                @Field("orderUuid") String orderUuid,
                                @Field("waitMile") double waitMile,
                                @Field("uploadText") String uploadText);

    // 到达目的地
    @FormUrlEncoded
    @POST("{apiPath}/arrive.yueyue")
    Observable<String> reqArrive(@Path(value = "apiPath", encoded = true) String apiPath,
                                 @Field("orderUuid") String orderUuid,
                                 @Field("tripDistance") double tripDistance,//单位：公里
                                 @Field("destAddress") String destAddress,
                                 @Field("destDetailAddress") String destDetailAddress,
                                 @Field("destCity") String destCity,
                                 @Field("destLng") double destLng,
                                 @Field("destLat") double destLat,
                                 @Field("uploadText") String uploadText);

    //保存订单金额
    @FormUrlEncoded
    @POST("{apiPath}/updFare.yueyue")
    Observable<String> reqUpdateFare(@Path(value = "apiPath", encoded = true) String apiPath,
                                     @Field("orderUuid") String orderUuid,
                                     @Field("actualFare") double actualFare);

    @FormUrlEncoded
    @POST("order/receiveCash.yueyue")
    Observable<String> receiveCash(@Field("orderUuid") String orderUuid, @Field("uploadText") String uploadText);

    /**
     * 投诉
     *
     * @param orderUuid
     * @param contents
     * @param remark
     * @return
     */
    @FormUrlEncoded
    @POST("complaint/add.yueyue")
    Observable<String> complainOrder(@Field("orderUuid") String orderUuid,
                                     @Field("contents") String contents,
                                     @Field("remark") String remark);

    /**
     * 取消订单
     *
     * @param orderUuid
     * @param cancelMsg
     * @return
     */
    @FormUrlEncoded
    @POST("order/cancel.yueyue")
    Observable<String> cancelOrder(@Field("orderUuid") String orderUuid,
                                   @Field("cancelMsg") String cancelMsg,
                                   @Field("uploadText") String uploadText);

    /**
     * 催款接口
     *
     * @param orderUuid
     * @return
     */
    @FormUrlEncoded
    @POST("order/rushFare.yueyue")
    Observable<String> rushFare(@Field("orderUuid") String orderUuid);

    /**
     * 获取投诉状态
     *
     * @param orderUuid
     * @return
     */
    @FormUrlEncoded
    @POST("order/isComplain.yueyue")
    Observable<ComplainResultEntity> isComplain(@Field("orderUuid") String orderUuid);

    /**
     * 司机取消说明接口
     *
     * @param orderUuid
     * @return
     */
    @FormUrlEncoded
    @POST("order/cancelDescription.yueyue")
    Observable<CancelDesEntity> cancelDescription(@Field("orderUuid") String orderUuid);

    /**
     * 获取"微信支付信息"接口
     *
     * @param orderUuid
     * @param spbillCreateIp
     * @return
     */
    @FormUrlEncoded
    @POST("pay/wx/tradeUrl")
    Observable<WxpayInfo> payByWechat(@Field("orderUuid") String orderUuid,
                                      @Field("spbillCreateIp") String spbillCreateIp);

    /**
     * 获取"支付宝支付信息"接口
     *
     * @param orderUuid
     * @return
     */
    @FormUrlEncoded
    @POST("pay/alipay/tradeUrl")
    Observable<String> payByAlipay(@Field("orderUuid") String orderUuid);

    /**
     * 余额支付
     *
     * @param orderUuid
     * @return
     */
    @FormUrlEncoded
    @POST("pay/balance/tradeUrl")
    Observable<String> payByBalance(@Field("orderUuid") String orderUuid);

    /**
     * 获取费用明细（出租车）
     *
     * @param orderUuid
     * @return
     */
    @FormUrlEncoded
    @POST("order/fareItems.yueyue")
    Observable<OrderCostEntity> fareItems(@Field("orderUuid") String orderUuid);

    /**
     * 获取实时费用明细（专车）
     *
     * @param orderUuid
     * @return
     */
    @FormUrlEncoded
    @POST("specialOrder/getRealtimeFare.yueyue")
    Observable<OrderCostEntity> getRealtimeFare(@Field("orderUuid") String orderUuid);

    /**
     * 获取费用明细（专车）
     *
     * @param orderUuid
     * @return
     */
    @FormUrlEncoded
    @POST("specialOrder/orderFare.yueyue")
    Observable<OrderCostEntity> orderFare(@Field("orderUuid") String orderUuid);

    /**
     * 确认费用（专车）
     *
     * @param orderUuid
     * @return
     */
    @FormUrlEncoded
    @POST("specialOrder/confirmFare.yueyue")
    Observable<String> confirmFare(@Field("orderUuid") String orderUuid,
                                   @Field("highwayFare") Integer highwayFare,
                                   @Field("roadBridgeFare") Integer roadBridgeFare,
                                   @Field("otherFare") Integer otherFare,
                                   @Field("uploadText") String uploadText);

    /**
     * 获取超时等待费
     *
     * @param orderUuid
     * @return
     */
    @FormUrlEncoded
    @POST("order/waitFare.yueyue")
    Observable<WaitFare> waitFare(@Field("orderUuid") String orderUuid);

    @POST("order/getAppointmentList.yueyue")//获取预约订单
    Observable<List<OrderSummaryEntity>> getAppointmentList();

    @FormUrlEncoded
    @POST("order/getFreshAppointmentCount.yueyue")//获取可抢订单
    Observable<CanGrapOrdersEntity> canGrapOrders(@Field("areaCode") String areaCode);

    @FormUrlEncoded
    @POST("order/getFreshAppointmentDetail.yueyue")
    Observable<List<OrderSummaryEntity>> getOrderPool(@Field("areaCode") String areaCode);
}
